#ifndef CLASSATTRIBUTE_H
#define CLASSATTRIBUTE_H

#include <QString>
#include <QUuid>
#include <QPen>

#include "uml/umltextchilditem.h"
#include "uml/umlvisibility.h"
#include "gui/editors/attributeeditor.h"
#include "gui/editors/highlighters/umlmethodhighlighter.h"

#define UML_PUBLIC "+"
#define UML_PRIVATE "-"
#define UML_PROTECTED "#"

#define HOVER_BACKGROUND_COLOR "#dee8f4"
#define PUBLIC_COLOR "#03a600"
#define PRIVATE_COLOR "#c60400"
#define PROTECTED_COLOR "#006fc6"

class UmlClassItem;
class ClassMethod;

class ClassAttribute : public UmlTextChildItem
{
    friend class UmlClassItem;

public:
    ClassAttribute(QGraphicsItem *parent = 0);
    ~ClassAttribute();

    UmlVisibility visibility();
    void setVisibility(UmlVisibility visibility);

    virtual void setVisibility(QString visibility);
    QString visibilityToString();
    QString umlVisibility();

    QString returnType();
    void setReturnType(QString type);

    QRectF umlTextRect();
    void setUmlTextRect(QRectF textRect);

    QRectF visibilityRect();
    void setVisiblityRect(QRectF visiblityRect);

    QPen visibilityPen();

    ClassMethod *getGetter();
    void setGetter(ClassMethod *getter);
    bool hasGetter();

    ClassMethod *getSetter();
    void setSetter(ClassMethod *setter);
    bool hasSetter();

    void setProject(UmlProject *project);

    UmlRelationalItem* boundingItem();

    void setClassItem(UmlClassItem *classItem);

    virtual void openEditor();

protected:
    UmlVisibility _visibility;
    QString _type;

    QRectF _visibilityRect;

    QPen _publicPen;
    QPen _privatePen;
    QPen _protectedPen;

    /// Hält eine Referenz auf die Klasse der dieses Attribut zugeordnet ist.
    UmlClassItem *_classItem;

    /// Hält eine Referenz auf den Getter-Methode die diesem Attribut zugeordnet ist.
    ClassMethod *_getter;

    /// Hält eine Referenz auf den Setter-Methode die diesem Attribut zugeordnet ist.
    ClassMethod *_setter;

    UmlMethodHighlighter *_highlighter;

    qreal _width;

protected slots:
    virtual void updateUmlText();
};

#endif // CLASSATTRIBUTE_H
